package com.xhwl.logistics.component;

import com.xhwl.logistics.enums.*;
import com.xhwl.logistics.strategy.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class LookupVehicleParkingLotHandler {

    @Autowired
    private ApplicationContext applicationContext;

    public IVehicleParkingLotHandler lookup(Integer productId) {
        return applicationContext.getBean(VehicleParkingLotHandlerEnum.toVehicleParkingLotHandlerEnum(productId).getHandlerName(), IVehicleParkingLotHandler.class);
    }

    public IVehicleParkingLotTokenHandler lookupForTokenHandler(Integer productId) {
        return applicationContext.getBean(VehicleParkingLotHandlerEnum.toVehicleParkingLotHandlerEnum(productId).getTokenHandlerName(), IVehicleParkingLotTokenHandler.class);
    }

    public IVehicleParkingLotFindCarHandler lookupForFindCarHandler(Integer productId) {
        return applicationContext.getBean(VehicleParkingLotFindCarHandlerEnum.toVehicleParkingLotFindCarHandlerEnum(productId).getFindCarHandlerName(), IVehicleParkingLotFindCarHandler.class);
    }

    public IVehicleParkingLotStatisticsHandler lookForStatisticsHandler(Integer productId) {
        return applicationContext.getBean(VehicleParkingLotStatisticsHandlerEnum.toVehicleParkingLotStatisticsHandlerEnum(productId).getStatisticsHandlerName(), IVehicleParkingLotStatisticsHandler.class);
    }

    public IVehicleParkingLotCarChargeHandler lookForCarChargeHandler(Integer productId) {
        return applicationContext.getBean(VehicleParkingLotCarChargeHandlerEnum.toVehicleParkingLotCarChargeHandlerEnum(productId).getCarChargeHandlerName(), IVehicleParkingLotCarChargeHandler.class);
    }

    public IVehicleParkingLotSyncHandler lookForSyncHandler(Integer productId) {
        return applicationContext.getBean(VehicleParkingLotSyncHandlerEnum.toVehicleParkingLotSyncHandlerEnum(productId).getSyncHandlerName(), IVehicleParkingLotSyncHandler.class);
    }

    public IVehicleParkingLotBlacklistHandler lookForBlacklistHandler(Integer productId) {
        return applicationContext.getBean(VehicleParkingLotBlacklistHandlerEnum.toVehicleParkingLotBlacklistHandlerEnum(productId).getBlacklistHandlerName(), IVehicleParkingLotBlacklistHandler.class);
    }

    public IVehicleParkingLotDeviceHandler lookForDeviceHandler(Integer productId) {
        return applicationContext.getBean(VehicleDeviceHandlerEnum.toVehicleDeviceHandlerEnum(productId).getDeviceHandlerName(), IVehicleParkingLotDeviceHandler.class);
    }
}
